package javabase;

import java.lang.reflect.Proxy;

import javabase.allimpl.SaySimpleImpl01;
import javabase.allinterface.SaySimple;

public class TestOfInvocationHandler {

    public static void main(String[] args) {
        SaySimple s = new SaySimpleImpl01();
        ImplInvocationHandler handle = new ImplInvocationHandler(s);
        
        SaySimple proxy = (SaySimple)Proxy.newProxyInstance(//TestOfInvocationHandler.class.getClassLoader(), 
                                                            handle.getClass().getClassLoader(),
                                                            //new Class[]{SaySimple.class},
                                                            s.getClass().getInterfaces(),
                                                            handle);
        proxy.sayHelloForSomeone("GY");
        
        SaySimple proxy2 = (SaySimple)handle.getProxy();
        proxy2.sayHelloForSomeone("WX");
    }

}
